home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / VertexAX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  7.2 KB  |  217 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38. #ifdef FUNCTION_PTRS
  39.   #define VERTEX_PTR_CALL (*vertexPtrCall)(vertexDim, type, stride, vertsPerBgnEnd, tmpVertexPtr);
  40.   #define NORMAL_PTR_CALL (*normalPtrCall)(type, stride, vertsPerBgnEnd, tmpNormalPtr);
  41.   #define COLOR_PTR_CALL (*colorPtrCall)(colorDim, type, stride, vertsPerBgnEnd, tmpColorPtr);
  42.   #define INDEX_PTR_CALL (*indexPtrCall)(type, stride, vertsPerBgnEnd, tmpIndexPtr);
  43.   #define TEX_PTR_CALL (*texPtrCall)(texDim, type, stride, vertsPerBgnEnd, tmpTexPtr);
  44.   #define DRAW_ARRAY_CALL (*drawArrayCall)(mode, first, vertsPerBgnEnd);
  45. #else
  46.   #define VERTEX_PTR_CALL glVertexPointerEXT(vertexDim, type, stride, vertsPerBgnEnd, tmpVertexPtr);
  47.   #define NORMAL_PTR_CALL glNormalPointerEXT(type, stride, vertsPerBgnEnd, tmpNormalPtr);
  48.   #define COLOR_PTR_CALL glColorPointerEXT(colorDim, type, stride, vertsPerBgnEnd, tmpColorPtr);
  49.   #define INDEX_PTR_CALL glIndexPointerEXT(type, stride, vertsPerBgnEnd, tmpIndexPtr);
  50.   #define TEX_PTR_CALL glTexCoordPointerEXT(texDim, type, stride, vertsPerBgnEnd, tmpTexPtr);
  51.   #define DRAW_ARRAY_CALL glDrawArraysEXT(mode, first, vertsPerBgnEnd);
  52. #endif
  53.  
  54. #define VERTEX_PTR VERTEX_PTR_CALL
  55. #define DRAW_ARRAY DRAW_ARRAY_CALL
  56.  
  57. #define SET_VERTEX_PTR tmpVertexPtr = vertexPtr;
  58. #define INCR_VERTEX_PTR tmpVertexPtr += bgnendSize;
  59.  
  60. #ifdef NORMAL_DATA
  61.   #define NORMAL_PTR NORMAL_PTR_CALL
  62.   #define SET_NORMAL_PTR tmpNormalPtr = normalPtr;
  63.   #define INCR_NORMAL_PTR tmpNormalPtr += bgnendSize;
  64. #else
  65.   #define NORMAL_PTR
  66.   #define SET_NORMAL_PTR
  67.   #define INCR_NORMAL_PTR
  68. #endif
  69.  
  70. #ifdef COLOR_DATA
  71.   #define COLOR_PTR COLOR_PTR_CALL
  72.   #define SET_COLOR_PTR tmpColorPtr = colorPtr;
  73.   #define INCR_COLOR_PTR tmpColorPtr += bgnendSize;
  74. #else
  75.   #define COLOR_PTR
  76.   #define SET_COLOR_PTR
  77.   #define INCR_COLOR_PTR
  78. #endif
  79.  
  80. #ifdef INDEX_DATA
  81.   #define INDEX_PTR INDEX_PTR_CALL
  82.   #define SET_INDEX_PTR tmpIndexPtr = indexPtr;
  83.   #define INCR_INDEX_PTR tmpIndexPtr += bgnendSize;
  84. #else
  85.   #define INDEX_PTR
  86.   #define SET_INDEX_PTR
  87.   #define INCR_INDEX_PTR
  88. #endif
  89.  
  90. #ifdef TEX_DATA
  91.   #define TEX_PTR TEX_PTR_CALL
  92.   #define SET_TEX_PTR tmpTexPtr = texPtr;
  93.   #define INCR_TEX_PTR tmpTexPtr += bgnendSize;
  94. #else
  95.   #define TEX_PTR
  96.   #define SET_TEX_PTR
  97.   #define INCR_TEX_PTR
  98. #endif
  99.  
  100. #define SET_PTRS SET_NORMAL_PTR \
  101.          SET_COLOR_PTR \
  102.          SET_INDEX_PTR \
  103.          SET_TEX_PTR \
  104.          SET_VERTEX_PTR
  105.  
  106. #define INCR_PTRS INCR_NORMAL_PTR \
  107.          INCR_COLOR_PTR \
  108.          INCR_INDEX_PTR \
  109.          INCR_TEX_PTR \
  110.          INCR_VERTEX_PTR
  111.  
  112. void FUNCTION (TestPtr thisTest)
  113. {
  114.     VertexPtr this = (VertexPtr)thisTest;
  115.     int i, j;
  116.     int iterations = this->iterations;
  117.     int numBgnEnds = this->numBgnEnds;
  118.     GLenum type = GL_FLOAT;
  119.     GLsizei vertsPerBgnEnd = this->vertsPerBgnEnd;
  120.     GLint first = 0;
  121.     GLint vertexDim = this->vertexDim;
  122.     GLsizei stride = this->vertexStride; 
  123.     GLsizei bgnendSize = this->bgnendSize; 
  124.     char* vertexPtr = this->vertexPtr; 
  125.     char* tmpVertexPtr;
  126.     GLenum mode = this->primitiveType;
  127. #ifdef NORMAL_DATA
  128.     char* normalPtr = this->normalPtr;
  129.     char* tmpNormalPtr;
  130. #endif
  131. #ifdef COLOR_DATA
  132.     GLint colorDim = this->colorDim;
  133.     char* colorPtr = this->colorPtr;
  134.     char* tmpColorPtr;
  135. #endif
  136. #ifdef INDEX_DATA
  137.     char* indexPtr = this->indexPtr;
  138.     char* tmpIndexPtr;
  139. #endif
  140. #ifdef TEX_DATA
  141.     GLint texDim = this->texDim;
  142.     char* texPtr = this->texPtr;
  143.     char* tmpTexPtr;
  144. #endif
  145. #ifdef FUNCTION_PTRS
  146.  #ifdef WIN32
  147.     void (APIENTRY *vertexPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glVertexPointerEXT;
  148.     void (APIENTRY *drawArrayCall)(GLenum, GLint, GLsizei) = glDrawArraysEXT;
  149.   #ifdef NORMAL_DATA
  150.     void (APIENTRY *normalPtrCall)(GLenum, GLsizei, GLsizei, const void*) = glNormalPointerEXT;
  151.   #endif
  152.   #ifdef COLOR_DATA
  153.     void (APIENTRY *colorPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glColorPointerEXT;
  154.   #endif
  155.   #ifdef INDEX_DATA
  156.     void (APIENTRY *indexPtrCall)(GLenum, GLsizei, GLsizei, const void*) = glIndexPointerEXT;
  157.   #endif
  158.   #ifdef TEX_DATA
  159.     void (APIENTRY *texPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glTexCoordPointerEXT;
  160.   #endif
  161.  #else
  162.     void (*vertexPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glVertexPointerEXT;
  163.     void (*drawArrayCall)(GLenum, GLint, GLsizei) = glDrawArraysEXT;
  164.   #ifdef NORMAL_DATA
  165.     void (*normalPtrCall)(GLenum, GLsizei, GLsizei, const void*) = glNormalPointerEXT;
  166.   #endif
  167.   #ifdef COLOR_DATA
  168.     void (*colorPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glColorPointerEXT;
  169.   #endif
  170.   #ifdef INDEX_DATA
  171.     void (*indexPtrCall)(GLenum, GLsizei, GLsizei, const void*) = glIndexPointerEXT;
  172.   #endif
  173.   #ifdef TEX_DATA
  174.     void (*texPtrCall)(GLint, GLenum, GLsizei, GLsizei, const void*) = glTexCoordPointerEXT;
  175.   #endif
  176.  #endif
  177. #endif
  178.  
  179.     for (i = iterations; i > 0; i--) {
  180.     SET_PTRS
  181.     for (j = numBgnEnds; j > 0; j--) {
  182.         VERTEX_PTR
  183.         NORMAL_PTR
  184.         COLOR_PTR
  185.         INDEX_PTR
  186.         TEX_PTR
  187.         DRAW_ARRAY
  188.         INCR_PTRS
  189.     }
  190.     }
  191. }
  192.  
  193. #undef VERTEX_PTR_CALL
  194. #undef NORMAL_PTR_CALL
  195. #undef COLOR_PTR_CALL
  196. #undef INDEX_PTR_CALL
  197. #undef TEX_PTR_CALL
  198. #undef DRAW_ARRAY_CALL
  199. #undef VERTEX_PTR
  200. #undef DRAW_ARRAY
  201. #undef NORMAL_PTR
  202. #undef COLOR_PTR
  203. #undef INDEX_PTR
  204. #undef TEX_PTR
  205. #undef SET_PTRS
  206. #undef INCR_PTRS
  207. #undef SET_NORMAL_PTR
  208. #undef SET_COLOR_PTR
  209. #undef SET_INDEX_PTR
  210. #undef SET_TEX_PTR
  211. #undef SET_VERTEX_PTR
  212. #undef INCR_NORMAL_PTR
  213. #undef INCR_COLOR_PTR
  214. #undef INCR_INDEX_PTR
  215. #undef INCR_TEX_PTR
  216. #undef INCR_VERTEX_PTR
  217.